package com.metaera.app.ui.adapters;

import android.content.Context;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.metaera.app.R;
import com.metaera.app.data.model.TodayEventResponse;
import com.metaera.app.ui.activities.FlashNewsDetailsActivity;
import com.metaera.app.utils.DateUtils;

import androidx.annotation.NonNull;

public class TodayEventListAdapter extends BaseQuickAdapter<TodayEventResponse, BaseViewHolder> {

    public TodayEventListAdapter() {
        super(R.layout.item_today_event);

        setOnItemClickListener((adapter, view, position) -> {
            Context context = view.getContext();
            context.startActivity(FlashNewsDetailsActivity.newInstance(context, getItem(position).getId()));
        });
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, TodayEventResponse item) {
        holder.setText(R.id.tv_date, DateUtils.getTime(item.getRelease_time_stamp(), DateUtils.PATTERN_5))
                .setText(R.id.tv_title, item.getTitle());
    }

}
